const rendom = require('../utils/rendom');
const serviceCommon = require('../utils/serviceCommon');
const CurriculumDao = require('../dao/CurriculumDao');

const server = {
    /**
     * 新增课程
     * */
    AddCurriculum: async (data) => {
        let CurriculumId = rendom.createUUID(), StageState = 0, result;
        data.CurriculumId = CurriculumId;
        data.StageState = StageState;
        result = await serviceCommon.addMethod(CurriculumDao, 'AddCurriculum', data);
        return result;
    },
    /**
     * 课程信息查询
     * */
    QueryCurriculum:async (data)=>{
        let result = await serviceCommon.searchMethod(CurriculumDao, 'QueryCurriculum', data);
        if(result.code===1){
            let res = await serviceCommon.searchMethod(CurriculumDao,'QueryCurriculumCount', data);
            result.Count= res.data[0].Count;
        }
        return result;
    },
    /**
     * 添加课程详情
     * */
    AddCurriculumDetails:async (data)=>{
        for(let i=0;i<data.CurriculumDetailsList.length;i++){
            data.CurriculumDetailsList[i].CurriculumDetailsId= rendom.createUUID();
        }
        let result = await serviceCommon.addMethod(CurriculumDao, 'AddCurriculumDetails', data);
        return result;
    },
    /**
     *
     * */
    QueryCurriculumDetails:async (data)=>{
        let result = await serviceCommon.searchMethod(CurriculumDao, 'QueryCurriculumDetails', data);
        return result
    }
};

module.exports = server;
